import pygame
import random
from Bullet import *
from EnemyBullet import *
from BasePlane import * # 飞机基类

'''敌人飞机'''
class EnemyPlane(BasePlane):
  def __init__(self, screen):
    super().__init__(screen, 0, 0, 'src/assets/images/enemy0.png')
    self.direaction = 'right'

  # def display(self):
  #   self.screen.blit(self.image, (self.x, self.y))
  #   for bullet in self.bulletList:
  #     bullet.display()
  #     bullet.move()
  #     if bullet.judge(): # 判断子弹是否越界
  #       self.bulletList.remove(bullet)

  def move(self):
    if self.direaction == 'right':
      self.x += 5
    elif self.direaction == 'left':
      self.x -= 5
    
    if self.x > 480 - 50:
      self.direaction = 'left'
    elif self.x < 0:
      self.direaction = 'right'

  def fire(self):
    randomNum = random.randint(1, 100)
    if randomNum == 80 or randomNum == 20:
      self.bulletList.append(EnemyBullet(self.screen, self))
    